<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<script>
			var locationtext = location.href.replace(/(file:\/{0,3})/, "");
			var txtname = locationtext.match(/[^\/\\]+$/)[0];
			var txtsrc = locationtext.replace(txtname, "");
			var fso, fsoTF = (!!window.ActiveXObject || "ActiveXObject" in window);
			if (fsoTF) {
				fso = new ActiveXObject("Scripting.FileSystemObject");
			};

			function $E(ids) {
				return document.getElementById(ids);
			};

			function deleteFolder(src) {
				if (!fso.FolderExists(src)) {
					return false;
				};
				try {
					fso.deleteFolder(src);
				} catch (e) {
					alert("deleteFolder\n    " + e.name + ":" + e.message);
				};
			};

			function deleteFile(src) {
				if (!fso.FileExists(src)) {
					return false;
				};
				try {
					fso.deleteFile(src);
				} catch (e) {
					alert("deleteFile:\n    " + e.name + ":" + e.message);
				};
			};

			function ExistsFile(src) {
				return fso.FileExists(src);
			};

			function ExistsFolder(src) {
				return fso.FolderExists(src);
			};

			function openF(src) {
				if (!ExistsFile(src)) {
					return false;
				};
				var t, f = fso.OpenTextFile(src, 1);
				if (f.AtEndOfLine) {
					return false;
				};
				t = f.ReadAll();
				f.Close();
				return t;
			};

			function cretF(src, str) {
				if (!src) return false;
				try {
					var f = fso.CreateTextFile(src);
					f.Write(str);
					f.Close();
				} catch (e) {
					alert("createTextFile:\n    " + e.name + ":" + e.message);
				};
			};

			function cretFD(src) {
				try {
					if (!ExistsFolder(src)) {
						fso.CreateFolder(src);
					};
				} catch (e) {};
			};

			function cretf(src, str) {
				try {
					var f = fso.CreateTextFile(src, true);
					f.write(str);
					f.close();
				} catch (e) {
					sendError(e.name, e.message);
				};
			};

			function openf(src) {
				if (!fso.FileExists(src)) {
					return false
				};
				try {
					var str, f = fso.OpenTextFile(src, 1);
					if (!f.AtEndOfLine) {
						str = f.ReadAll();
						f.close();
					} else {
						return false
					};
					return str;
				} catch (e) {
					sendError(e.name, e.message);
				};
			};

			function openStorage(nam) {
				var t;
				if (localStorage) {
					t = localStorage.getItem(nam);
				} else {
					var cA, c = document.cookie;
					if (typeof c != 'string' || c.length < 2) {
						return false;
					} else {
						c = c.split(";");
					};
					for (var i = 0; i < c.length; i++) {
						cA = c[i].split("=");
						cA[0] = cA[0].replace(/(^\s+)|(\s+$)/g, "");
						cA[1] = unescape(cA[1]);
						if (nam == cA[0]) {
							t = cA[1];
							break;
						};
					};
				};
				if (t) {
					return t;
				} else {
					return false;
				};
			};

			function cretStorage(nam, str) {
				if (localStorage) {
					localStorage.setItem(nam, str);
				} else {
					document.cookie = nam + "=" + escape(str) + ";expires=" + new Date(new Date().getTime() + 31 * 86400000)
						.toUTCString();
				};
			};

			function sendError(s1, s2) {
				var str = (s1 ? s1 : "") + (s2 ? s2 : "");
				alert(str);
			};

			function ExistsDomElm(obj) {
				if (typeof(obj) == "string" && $E(obj)) {
					return $E(obj);
				} else if (typeof(obj) == "object" && obj.nodeType == 1) {
					return obj;
				};
			};

			function returnError(e) {
				if (!(navigator.appName == "Microsoft Internet Explorer")) {
					return {
						name: e.name,
						message: e.message,
						lineNumber: e.lineNumber,
						fileName: e.fileName,
						stack: e.stack
					};
				} else {
					return {
						name: e.name,
						errorNumber: (e.number & 0xFFFF),
						message: e.message
					};
				};
			}

			function styFunction() {
				this.get = function(obj, sty) {

				}
				this.set = function(obj, sty) {
					if (!obj || !sty || typeof(sty) != "string") {
						return false
					};

					var objs = [],
						Sty = [],
						o;
					sty = sty.replace(/(\;$)|(^\;)/g, "").split(";");
					if (typeof(obj) == "string" || (typeof(obj) == "object" && obj.nodeType == 1)) {
						objs[0] = obj;
					} else if (typeof(obj) == "object" && !obj.length) {
						objs = [];
					} else {
						objs = obj;
					};
					for (var i = 0; i < sty.length; i++) {
						Sty.push([sty[i].slice(0, sty[i].indexOf(":")), sty[i].slice(sty[i].indexOf(":") + 1, sty[i]
							.length)]);
					};
					for (var i = 0; i < objs.length; i++) {
						o = ExistsDomElm(objs[i]);
						if (o && o.nodeType == 1) {
							for (var k = 0; k < Sty.length; k++) {
								o.style[Sty[k][0]] = Sty[k][1];
							};
						};
					};
				};
			};
			var Stys = new styFunction();
			var getKeys;

			function tipTF() {
				var t = document.activeElement.tagName.toUpperCase();
				if (t == "TEXTAREA" || t == "INPUT") {
					return false;
				} else {
					return true;
				};
			};

			function stopEvents(e) {
				if (e.preventDefault) {
					e.preventDefault();
				} else {
					e.returnValue = false;
				};
			};

			function stopBubble(e) {
				if (e.stopPropagation) {
					e.stopPropagation();
				} else {
					e.cancelBubble = true;
				};
			};
			document.onkeydown = function(e) {
				e = e || window.event;
				keyAct = document.activeElement;
				if (tipTF() && e.keyCode == 27) {
					stopEvents(e);
					if (getKeys.display()) {
						getKeys.display(false);
					} else {
						getKeys.display(true);
						getKeys.show();
					};
				} else if (tipTF() && e.keyCode == 32) {
					getKeys.show();
				};
			};
			var FREE;
			window.onbeforeunload = function() {
				try {
					FREE.close();
					FREE.deleteSelf();
				} catch (e) {
					alert(FREE + "- " + e.name + ":" + e.message);
				};
			};
			window.onload = function() {
				Stys.set("freeBigBox",
					"width:1300px;height:900px;background:#FFF;border:2px solid black;position:relative;left:0;top:0;margin:auto;"
				);

				Stys.set("freeLists", "width:100px;height:850px;background:#333;position:absolute;left:0;top:0");
				Stys.set("freeBox",
					"width:800px;height:800px;background:#DC7;textAlign:center;position:absolute;left:300px;top:50px;");
				Stys.set("freeBnr", "width:1300px;height:50px;background:#555;position:absolute;bottom:0;left:0;");
				Stys.set("freeMsg", "width:1200px;height:50px;background:#225;position:absolute;left:100px;top:0");

				Stys.set($E("freeLists").children, "width:100px;fontSize:18px;");
				Stys.set($E("freeBnr").children,
					"width:80px;height:30px;fontSize:12px;border:none;background:#777;vertical:middle;margin:10px 3px;");
				Stys.set($E("freeMsg").children, "height:50px;fontSize:24px;position:absolute;top:0;");

				Stys.set(["freeBox1", "freeBox2"], "position:absolute;");

				Stys.set("freeMsg0", "width:100px;left:0;color:#FAA;fontSize:16px;textAlign:center;lineHeight:50px;");
				Stys.set("freeMsg1", "width:900px;left:100px;color:#AAF;textAlign:center;lineHeight:50px;");
				Stys.set("freeMsg2", "width:200px;right:0;fontSize:12px;background:none;");

				Stys.set(["player1", "player2"],
					"width:95px;height:20px;fontSize:14px;color:black;border:none;background:#777;verticalAlign:middle;");
				Stys.set(["player1"], "margin:4px 2px 0px 3px;");
				Stys.set(["player2"], "margin:4px 3px 0px 2px;");
				Stys.set(["player1tim", "player2tim"],
					"width:95px;height:20px;color:#ACC;border:none;background:#245;verticalAlign:middle;");
				Stys.set(["player1tim"], "margin:0px 2px 5px 3px;");
				Stys.set(["player2tim"], "margin:0px 3px 5px 2px;");

				Stys.set("freeLists3", "height:25px;color:red;border:none;background:#322;");
				Stys.set("freeLists2", "height:800px;overflow:hidden;");
				Stys.set("freeLists1", "height:25px;color:#CCF;textAlign:center;");

				Stys.set("testEvalArea", "width:300px;height:40px;border:none;background:#999;color:white;display:block;");
				Stys.set("showevalError", "width:300px;height:40px;border:none;background:#555;color:#AFF;display:block;");

				cretFD(txtsrc + "Zone/");
				FREE = new FREEFunction(txtsrc + "Zone/");
				FREE.initBoxUI(30, 16);
				var drg2 = chger_Drager("freeLists");
				var siz1 = chger_Resizer("freeLists");
				var siz2 = chger_Resizer("freeBigBox");

				getKeys = new getKeyTable();
				setInterval(getKeys.show, 500);

				initClicks();
			};

			function initClicks() {
				$E("freeLists3").onclick = function() {
					var t = this.innerHTML;
					if (t.length) {
						FREE.A_Guest("#" + t, true);
					};
				};
				$E("freeBnr1").onclick = function() {
					FREE.startCreateRoom();
				};
				$E("freeBnr2").onclick = function() {
					FREE.C_Ready();
				};
				$E("player1").onclick = function() {
					FREE.B_Player("player1");
				};
				$E("player2").onclick = function() {
					FREE.B_Player("player2");
				};
			}
		</script>
	</head>

	<body>
		<div id="freeBigBox">
			<div id="freeLists">
				<div id="freeLists1">标题</div>
				<div id="freeLists2"></div>
				<button id="freeLists3">确认</button>
			</div>
			<div id="freeBox">
				<div id="freeBox1"></div>
				<div id="freeBox2"></div>
				<div id="freeBox3"></div>
			</div>
			<div id="freeBnr">
				<button id="freeBnr1">创建房间</button>
				<button id="freeBnr2">就绪</button>
				<button id="freeBnr3">name</button>
			</div>
			<div id="freeMsg">
				<div id="freeMsg0">FREE ROOM</div>
				<div id="freeMsg1">FREE GAME</div>
				<div id="freeMsg2"><button id="player1">1</button><button id="player2">2</button><button
						id="player1tim">00:00:00</button><button id="player2tim">00:00:00</button></div>
			</div>
		</div>
		<div style="position:absolute;left:5px;bottom:4px;border:1px solid red;">
			<textarea id="testEvalArea"
				onblur="try{$E('showevalError').value=eval(this.value);}catch(e){$E('showevalError').value=e.name+':'+e.message;};"></textarea>
			<textarea id="showevalError" onblur="try{}catch(e){};"></textarea>
		</div>
		<script src="./drag.js"></script>
		<script src="helper.js"></script>
		<script src="chessboard.js"></script>
	</body>
</html>